import React from "react";
import GoodNode from "../../../Component/Good";
// import './index.css';
import TradeServer from "../../../Server/Trade/TradeServer";
import UserCheck from "../../../utils/UserCheck";
import URL from "../../../Server/URL";
import MessageUtil from "../../../utils/MessageUtil";
import Common from "../../../utils/Common";

export default class extends React.Component {

    constructor(props) {
        super();

        let goods=[];

        this.state={
            goods
        }

        MessageUtil.ShowSuspention("MyPublish");

        let state=[ "接单中","已接单","已完成","已取消"]

        TradeServer.SendSellSelectMySendSellList(UserCheck.GetUserID(),0,1)
        .then((response)=>{
            response.data.forEach(i => {
                // console.log(i)

                let stateInfo="";
                let color="";
                switch(i.sendSell.status){
                    case "0":
                        color="red";
                        // color="#5393EB";//blue
                        break;
                    case "1":
                        color="#61BC12";
                        break;
                    case "2":
                        color="#61BC12";//green
                        break;
                    default:
                        break;
                }
                stateInfo=<span>派单状态: <font color={color}>{state[i.sendSell.status]}</font></span>
                let timeStr=Common.GetTimeStr(i.sendSell.time);
                goods.push(
                    <GoodNode header={ URL.GetURL(i.userHead)}
                    key={i}
                    insurance={false}
                    guaranteeMoney={false}
                    modify={false} order={true} 
                    heart={false} 
                    bag={false} delete={false} 
                    name={i.sendSell.title}
                    time={timeStr}
                    desc={`拍摄地点: ${i.sendSell.shootingAddress}`}
                    state={stateInfo}
                    price={i.sendSell.shootingMoney}
                    />
                )
            });

            this.setState({
                goods
            },()=>{
                MessageUtil.ChangeHeight();
            })
        });
    }

    render() {
        return (
            <div>
                <div className="">
                    {this.state.goods}
                </div>
            </div>
        );
    }
}